package com.bw.module_detail.adapter

import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide
import com.bw.module_detail.R

object ImageBindingAdapter {
    @BindingAdapter("imageUrl")
    @JvmStatic
    fun loadImage(view: ImageView, url:String?){
        if (url.isNullOrEmpty()){
            view.setImageResource(R.drawable.ic_launcher_background)
            return
        }

        Glide.with(view.context)
            .load(url)
            .placeholder(R.drawable.ic_launcher_foreground)
            .error(R.drawable.ic_launcher_foreground)
            .into(view)

    }
}